<fieldset>
	<legend>Thông tin sinh viên thực tập</legend>
	<table class="job_info large-12 columns job_detail">
		<tbody>
			<tr>
				<td class="first_col">Hình đại diện:
				<td style="text-align: center;"><img class="preview" src="<?php echo $info['avatar']; ?>" alt=""></td>
			</tr>
			<tr>
				<td class="first_col">Mã số sinh viên:
				<td>
		      		<?php echo $info['mssv'] ?>
				</td>
			</tr>
			<tr>
				<td class="first_col">Tên sinh viên:
				<td>
		      		<?php echo $info['ho']." ".$info['ten'] ?>
				</td>
			</tr>
			<tr>
				<td class="first_col">Ngày sinh:
				<td>
					<?php echo date('d-m-Y',strtotime($info['ngay_sinh'])) ?>
				</td>
			</tr>
			<tr>
				<td class="first_col">Giới tính:
				<td>
					<?php  
						if($info['gioi_tinh'] == "M") echo "Nam";
						else echo "Nữ";
					?>
				</td>
			</tr>
			<tr>
				<td class="first_col">Số điện thoại:
				<td>
					<?php echo $info['sdt'] ?>
				</td>
			</tr>
			<tr>
				<td class="first_col">Địa chỉ:
				<td>
					<?php echo $info['dia_chi'] ?>
				</td>
			</tr>
		</tbody>
	</table>
</fieldset>

<?php  
	if($cv){
		echo "<fieldset>";
			echo "<legend>Thông tin hồ sơ sinh viên</legend>";
			echo "<table class='job_info large-12 columns'>";
				echo "<tbody>";
					echo "<tr><td class='first_col'>Tên hồ sơ:</td><td>".$cv['ten_hs']."</td></tr>";
					echo "<tr><td class='first_col'>Địa chỉ thực tập mong muốn:</td><td>".$cv['dia_chi']."</td></tr>";
					echo "<tr><td class='first_col'>Mức lương mong muốn:</td><td>".$cv['luong']."</td></tr>";
					echo "<tr><td class='first_col'>Hình thức thực tập mong muốn:</td><td>".$cv['hinhthuc_tt']."</td></tr>";
					echo "<tr><td class='first_col'>Kinh nghiệm:</td><td>";
						$kinh_nghiem = explode("\n",$cv['kinh_nghiem']);
						foreach ($kinh_nghiem as $str) {
						 	echo $str."<br />";
						}
						echo "</td></tr>";
					echo "<tr><td class='first_col'>Kĩ năng:</td><td>";
						$ki_nang = explode("\n",$cv['ki_nang']);
						foreach ($ki_nang as $str) {
						 	echo $str."<br />";
						}
						echo "</td></tr>";
					echo "<tr><td class='first_col'>Thành tích:</td><td>";
						$thanh_tich = explode("\n",$cv['thanh_tich']);
						foreach ($thanh_tich as $str) {
						 	echo $str."<br />";
						}
						echo "</td></tr>";
					echo "<tr><td class='first_col'>Mục tiêu trong tương lai:</td><td>";
						$muc_tieu = explode("\n",$cv['muc_tieu']);
						foreach ($muc_tieu as $str) {
						 	echo $str."<br />";
						}
						echo "</td></tr>";
					echo "<tr><td class='first_col'>Bằng cấp:</td><td>";
						$bang_cap = explode("\n",$cv['bang_cap']);
						foreach ($bang_cap as $str) {
						 	echo $str."<br />";
						}
						echo "</td></tr>";
					echo "<tr><td class='first_col'>Thời gian tốt nghiệp:</td><td>".date('d-m-Y',strtotime($cv['thoigian_tn']))."</td></tr>";
					if($cv['cv']){
							$file = trim(strrchr($cv['cv'], "/"),"/");
							echo "<tr>";
							echo "<td class='first_col'>CV đính kèm:";
							echo "<td><a href='".base_url()."student/download/".$file."'>".$file."</a></td>";
							echo "</tr>";
						}
				echo "</tbody>";
			echo "</table>";
		echo "</fieldset>";
	}
?>

<?php
	if(isset($comment) && count($comment)){
		echo "<hr>";
		$i = 1;
		echo '<dl class="accordion" data-accordion>';
			foreach ($comment as $key => $val) {
				$time = explode(' ', $val['thoi_gian']);
				$time_bd = $time[1];
				$time_kt = $time[3];
				if(strlen($val['ti_le']) == 2){
					$ti_le = substr( $val['ti_le'], 0, 1 );
				}elseif (strlen($val['ti_le']) == 3) {
					$ti_le = substr( $val['ti_le'], 0, 2 );
				}elseif (strlen($val['ti_le']) == 4) {
					$ti_le = substr( $val['ti_le'], 0, 3 );
				}
				echo '<dd class="accordion-navigation">';
					echo '<a href="#panel'.$i.'b">Nhận xét lần '.$i.'</a>';
					echo '<div id="panel'.$i.'b" class="content">';
						// echo '<form action="'.base_url().'employer/delete_comment/'.$val['id'].'" method="post" data-abide accept-charset="utf-8">';
			        	echo '<fieldset>
				        		<legend>Nhận xét lần '.$i.'</legend>
				        		<table class="job_info large-12 columns job_detail">
				        			<tbody>
				        				<tr>
											<td class="first_col">Người nhận xét:
											<td>'.$val['ten'].'</td>
				        				</tr>
				        				<tr>
											<td class="first_col">Ngày nhận xét:
											<td>'.date('d-m-Y',strtotime($val['ngay_nx'])).'</td>
				        				</tr>
				        				<tr>
											<td class="first_col">Nội dung công việc:
											<td>';
												$task = explode("\n", $val['task']);
												foreach ($task as $str) {
													echo $str."<br />";
												}
											echo '</td>
				        				</tr>
				        				<tr>
											<td class="first_col">Thời gian công việc:
											<td>Từ '.date('d-m-Y',strtotime($time_bd)).' đến '.date('d-m-Y',strtotime($time_kt)).'</td>
				        				</tr>
				        				<tr>
											<td class="first_col">Tỉ lệ hoàn thành:
											<td>'.$val['ti_le'].'</td>
				        				</tr>
				        				<tr>
											<td class="first_col">Nhận xét:
											<td>';
												$nhan_xet = explode("\n", $val['nhan_xet']);
												foreach ($nhan_xet as $str) {
													echo $str."<br />";
												}
											echo '</td>
				        				</tr>
				        			</tbody>	
				        		</table>
				        	</fieldset>';
			        	// echo '<input type="hidden" name="id_cv" value="'.$info['id_cv'].'">';
						// echo '<input type="hidden" name="mssv" value="'.$info['mssv'].'">';
						// echo '<button type="submit" class="radius" onclick="delete_job('.$val['id'].')">Xoá</button>';
						// echo '</form>';
						if($this->session->userdata('level') == 3){
					        echo "<a href='#' title='Xoá công việc' onclick='delete_job(".$val['id'].",".$info['id_cv'].",".$info['mssv'].")'><button type='button' class='radius'>Xoá</button></a>";
					        echo '&nbsp;&nbsp;&nbsp; <a href="#" data-reveal-id="myModal'.$i.'"><button type="button" class="radius">Sửa</button></a>';
								echo 	'<div id="myModal'.$i.'" class="reveal-modal remove-whitespace" data-reveal>
								  			<form action="'.base_url().'leader/edit_comment/'.$val['id'].'" method="post" data-abide accept-charset="utf-8">
								  				<fieldset>
													<legend>Thông tin nhận xét</legend>
													<table class="job_info large-12 columns">
														<tbody>
															<tr>
																<td class="first_col">Nội dung công việc:<small>*</small></td>
																<td>
																	<textarea name="task" cols="50" rows="3" style="resize: none;" required>'.$val['task'].'</textarea>
																	<small class="error">This field must match the requirements</small>
																</td>
															</tr>
															<tr>
																<td class="first_col">Trong thời gian:<small>*</small></td>
																<td>
																	Từ: <input style="width:30%; display: inline;" type="date" name="bd" value="'.$time_bd.'" placeholder="">
																	Đến: <input style="width:30%; display: inline;" type="date" name="kt" value="'.$time_kt.'" placeholder="">
																</td>
															</tr>
															<tr>
																<td class="first_col">Tỉ lệ hoàn thành:<small>*</small></td>
																<td>
																	<form>
																	    <input style="width: 200px" type="range" name="amountRange" min="0" max="100" value="0" oninput="this.form.amountInput.value=this.value" />
																	    <input style="width: 70px; display: inline" type="number" name="amountInput" min="0" max="100" value="'.$ti_le.'" oninput="this.form.amountRange.value=this.value" />
																	</form>
																</td>
															</tr>
															<tr>
																<td class="first_col">Nhận xét:<small>*</small></td>
																<td>
																	<textarea name="nhan_xet" cols="50" rows="5" style="resize: none;" required>'.$val['nhan_xet'].'</textarea>
																	<small class="error">This field must match the requirements</small>
																</td>
															</tr>		
														</tbody>
													</table>
													<input type="hidden" name="id_cv" value="'.$info['id_cv'].'">
													<input type="hidden" name="mssv" value="'.$info['mssv'].'">
												</fieldset>
								  				<button type="submit" class="radius">Cập nhật</button>
							  				</form>
										</div>';
									}
				    echo '</div>';
				echo '</dd>';
				$i++;
			}
		echo '</dl>';
	}
	if($info['trangthai_dn'] == 1 && $info['trangthai_sv'] == 1 && $this->session->userdata('level') == 3){
		echo "<hr>";
		echo '<a href="#" data-reveal-id="myModal" class="button">Nhận xét sinh viên</a>';
		echo 	'<div id="myModal" class="reveal-modal remove-whitespace" data-reveal>
		  			<form action="'.base_url().'leader/add_comment" method="post" data-abide accept-charset="utf-8">
		  				<fieldset>
							<legend>Thông tin nhận xét</legend>
							<table class="job_info large-12 columns">
								<tbody>
									<tr>
										<td class="first_col">Nội dung công việc:<small>*</small></td>
										<td>
											<textarea name="task" cols="50" rows="3" style="resize: none;" required></textarea>
											<small class="error">This field must match the requirements</small>
										</td>
									</tr>
									<tr>
										<td class="first_col">Trong thời gian:<small>*</small></td>
										<td>
											Từ: <input style="width:30%; display: inline;" type="date" name="bd" value="" placeholder="">
											Đến: <input style="width:30%; display: inline;" type="date" name="kt" value="" placeholder="">
										</td>
									</tr>
									<tr>
										<td class="first_col">Tỉ lệ hoàn thành:<small>*</small></td>
										<td>
											<form>
											    <input style="width: 200px" type="range" name="amountRange" min="0" max="100" value="0" oninput="this.form.amountInput.value=this.value" />
											    <input style="width: 70px; display: inline" type="number" name="amountInput" min="0" max="100" value="0" oninput="this.form.amountRange.value=this.value" />
											</form>
										</td>
									</tr>
									<tr>
										<td class="first_col">Nhận xét:<small>*</small></td>
										<td>
											<textarea name="nhan_xet" cols="50" rows="5" style="resize: none;" required></textarea>
											<small class="error">This field must match the requirements</small>
										</td>
									</tr>		
								</tbody>
							</table>
							<input type="hidden" name="id_cv" value="'.$info['id_cv'].'">
							<input type="hidden" name="mssv" value="'.$info['mssv'].'">
						</fieldset>
		  				<button type="submit" class="radius">Nhận xét</button>
	  				</form>
				</div>';
	}
?>

<script type="text/javascript">
	function delete_job(id, id_cv, mssv) {
		if(confirm("Bạn có chắc chắn muốn xoá?") == true){
			window.location.href = "<?php echo base_url() ?>leader/delete_comment/"+id+"/"+id_cv+"/"+mssv;
		}
	}
</script>